<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<link href="css/createNiumaInfo.css" rel="stylesheet" />
	</head>

	<body>


		<div id="app">


			<header class="mui-bar mui-bar-nav">
				<h1 class="mui-title">第二章:{{niumaLevel | niumaLevelFilter}}童年({{userInfo.days | day2DateFilter}})</h1>
			</header>


			<div class="mui-content">

				<div class="mui-card">
					<div class="mui-card-header mui-card-media"
						style="height:40vw;background-image:url(pic/0-year-cry.gif)">
					</div>
					<div class="mui-card-content">
						<div class="mui-card-content-inner">
							<ul class="mui-table-view mui-grid-view">
								<li class="mui-table-view-cell mui-media mui-col-xs-3">姓名:{{userInfo.name}}</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3">年龄:{{userInfo.age}}</li>
								<!-- <li class="mui-table-view-cell mui-media mui-col-xs-3">健康度:{{userInfo.luck}}</li> -->
								<li class="mui-table-view-cell mui-media mui-col-xs-3">智力:{{userInfo.IQ}}</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3" :style="processEnergyNowStyle()">
									体力:{{userInfo.energyNow}}</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3">运气:{{userInfo.luck}}</li>
								<!-- <li class="mui-table-view-cell mui-media mui-col-xs-3">个人存款:{{userInfo.money}}</li> -->
								<li class="mui-table-view-cell mui-media mui-col-xs-3">
									存款:{{userInfo.parentMoney | moneyFilter}}
								</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3">
									比特币持仓:{{userInfo.bitCoinCount}}
								</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3">健康:{{userInfo.health}}</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3" :style="processHungerStyle()">
									饥饿:{{userInfo.hunger}}</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3" :style="processCleanStyle()">
									干净:{{userInfo.clean}}</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3" :style="processHappyStyle()">
									心情:{{userInfo.happy}}</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3">
									形象:{{userInfo.appearance}}</li>
								<li class="mui-table-view-cell mui-media mui-col-xs-3">
									声誉:{{userInfo.reputation | reputationFilter}}</li>

							</ul>
						</div>
					</div>
					<div id="Gallery" class="mui-slider" style="margin-top:15px;">
						<div class="mui-slider-group">
							<div class="mui-slider-item">
								<ul class="mui-table-view mui-grid-view mui-grid-9">
									<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#" @click="weinai()">
											<div class="mui-media-body">喂奶</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#" @click="douhaizi()">
											<div class="mui-media-body">逗娃</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#" @click="xizao()">
											<div class="mui-media-body">洗澡</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#" @click="kanbing()">
											<div class="mui-media-body">看病</div>
										</a>
									</li>



									<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#" @click="makeMoney()">
											<div class="mui-media-body">打工</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#" @click="chaoBitCoin()">
											<!-- ({{bitCoinTips}}) -->
											<div class="mui-media-body">货币</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#" @click="toClothingStore()">
											<div class="mui-media-body">商城</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#" @click="toHouse()">
											<div class="mui-media-body">房产</div>
										</a>
									</li>
									<li @click="rentBaomu()" v-show="userInfo.houseList.length>0"
										class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-4">
										<a href="#">
											<div class="mui-media-body">保姆</div>
										</a>
									</li>
								</ul>
							</div>
							<div class="mui-slider-item">
								<ul class="mui-table-view mui-grid-view mui-grid-9">
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-home"></span>
											<div class="mui-media-body">买车(功能开发中)</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<div class="mui-media-body">买房(功能开发中)</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-chatbubble"></span>
											<div class="mui-media-body">赌博(功能开发中)</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-location"></span>
											<div class="mui-media-body">location</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-search"></span>
											<div class="mui-media-body">Search</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-phone"></span>
											<div class="mui-media-body">Phone</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-gear"></span>
											<div class="mui-media-body">Setting</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-info"></span>
											<div class="mui-media-body">about</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#" @click="moreMoney()">
											<span class="mui-icon mui-icon-more"></span>
											<div class="mui-media-body">more</div>
										</a>
									</li>
								</ul>
							</div>
							<div class="mui-slider-item">
								<ul class="mui-table-view mui-grid-view mui-grid-9">
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-home"></span>
											<div class="mui-media-body">Home</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-email"><span
													class="mui-badge">5</span></span>
											<div class="mui-media-body">Email</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-chatbubble"></span>
											<div class="mui-media-body">Chat</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-location"></span>
											<div class="mui-media-body">location</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-search"></span>
											<div class="mui-media-body">Search</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-phone"></span>
											<div class="mui-media-body">Phone</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-gear"></span>
											<div class="mui-media-body">Setting</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-info"></span>
											<div class="mui-media-body">about</div>
										</a>
									</li>
									<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
										<a href="#">
											<span class="mui-icon mui-icon-more"></span>
											<div class="mui-media-body">more</div>
										</a>
									</li>
								</ul>
							</div>

						</div>


					</div>
				</div>

				<button type="button" class="mui-btn mui-btn-grey mui-btn-outlined mui-btn-block"
					@click="nextDay()">下一天(恢复体力)</button>

			</div>


		</div>













		<script src="js/util.js"></script>
		<script src="js/db.js"></script>
		<script src="js/mui.js"></script>
		<script src="js/vue-min.js"></script>
		<script type="text/javascript">
			mui.init()


			var app = new Vue({
				el: '#app',
				data: {
					niumaLevel: 1,
					userInfo: {
						niumaLevel: 3,
						name: '',
						age: 0,
						IQ: 10,
						luck: 100,
						// money: 0,1111
						energyMax: 100,
						energyNow: 100,
						parentMoney: 2000,
						health: 100,
						hunger: 50,
						clean: 50,
						happy: 50,
						days: 1,
						healthLogs: [],
						bitCoinCount: 0,
						bitCoinTradeLog: [],
						bitCoinBuyAvg: 0,
						bitCoinProfit: 0,
						changeArr: [213.06, 1824.48, 1913.19, 1000.02, 1500.85, 562.54, 1401.34, 1847.38,
							986.07, 29.67, 1899.80, 845.65, 301.77, 940.28, 63.72, 1877.40,
							1115.50, 657.85, 1279.25, 80.96, 1381.79, 907.53, 1459.61, 200.13
						],
						todayWorkCount: 0,
						appearance: 0,
						clothingList: [],
						houseList: [],
						reputation: 0,
						baomuCareDay: 0
					},

					nameList: ['建国', '二蛋', '狗蛋', '三胖'],
					bitCoinTips: ''
				},
				computed: {
					// weinaiStyle() {
					// 	return {
					// 		'background-color': this.processWeinaiStyle()
					// 	};
					// }
				},
				methods: {
					processHungerStyle() {
						if (this.userInfo.hunger > 30 && this.userInfo.hunger <= 65) {
							return {
								'background-color': 'yellow'
							};
						} else if (this.userInfo.hunger > 65) {
							return {
								'background-color': 'Red'
							};
						} else if (this.userInfo.hunger <= 30) {
							return {
								'background-color': 'lightGreen'
							};
						}
					},
					processCleanStyle() {
						if (this.userInfo.clean > 30 && this.userInfo.clean < 100) {
							return {
								'background-color': 'yellow'
							};
						} else if (this.userInfo.clean >= 100) {
							return {
								'background-color': 'lightGreen'
							};
						} else if (this.userInfo.clean <= 30) {
							return {
								'background-color': 'red'
							};
						}
					},
					processHappyStyle() {
						if (this.userInfo.happy >= 50 && this.userInfo.happy < 100) {
							return {
								'background-color': 'yellow'
							};
						} else if (this.userInfo.happy >= 100) {
							return {
								'background-color': 'lightGreen'
							};
						} else if (this.userInfo.happy < 50) {
							return {
								'background-color': 'red'
							};
						}
					},
					processEnergyNowStyle() {
						if (this.userInfo.energyNow >= this.userInfo.energyNow < (this.userInfo.energyMax / 2) && this
							.userInfo.energyNow < this.userInfo.energyMax) {
							return {
								'background-color': 'yellow'
							};
						} else if (this.userInfo.energyNow == this.userInfo.energyMax) {
							return {
								'background-color': 'lightGreen'
							};
						} else if (this.userInfo.energyNow < this.userInfo.energyNow < (this.userInfo.energyMax / 2)) {
							return {
								'background-color': 'red'
							};
						}
					},
					initUserInfoByNiumaLevel() {

						if (Database.getData('userInfo') == null) {
							switch (this.niumaLevel) {
								case 1:
									this.userInfo = {
										niumaLevel: 1,
										name: '狗蛋',
										age: 0,
										IQ: 10,
										luck: 100,
										// money: 0,
										energyMax: 100,
										energyNow: 100,
										parentMoney: 100000,
										health: 100,
										hunger: 50,
										clean: 50,
										happy: 50,
										days: 1,
										healthLogs: [],
										bitCoinCount: 0,
										bitCoinTradeLog: [],
										bitCoinBuyAvg: 0,
										bitCoinProfit: 0,
										changeArr: [213.06, 1824.48, 1913.19, 1000.02, 1500.85, 562.54, 1401.34,
											1847.38,
											986.07, 29.67, 1899.80, 845.65, 301.77, 940.28, 63.72, 1877.40,
											1115.50, 657.85, 1279.25, 80.96, 1381.79, 907.53, 1459.61, 1200.13
										],
										todayWorkCount: 0,
										appearance: 0,
										clothingList: [],
										houseList: [],
										reputation: 0,
										baomuCareDay: 0
									}
									break;

								case 2:
									this.userInfo = {
										niumaLevel: 2,
										name: '狗蛋',
										age: 0,
										IQ: 10,
										luck: 70,
										// money: 0,
										energyMax: 80,
										energyNow: 80,
										parentMoney: 2000,
										health: 80,
										hunger: 50,
										clean: 50,
										happy: 50,
										days: 1,
										healthLogs: [],
										bitCoinCount: 0,
										bitCoinTradeLog: [],
										bitCoinBuyAvg: 0,
										bitCoinProfit: 0,
										changeArr: [213.06, 1824.48, 1913.19, 1000.02, 1500.85, 562.54, 1401.34,
											1847.38,
											986.07, 29.67, 1899.80, 845.65, 301.77, 940.28, 63.72, 1877.40,
											1115.50, 657.85, 1279.25, 80.96, 1381.79, 907.53, 1459.61, 1200.13
										],
										todayWorkCount: 0,
										appearance: 0,
										clothingList: [],
										houseList: [],
										reputation: 0,
										baomuCareDay: 0
									}
									break;

								case 3:
									this.userInfo = {
										niumaLevel: 3,
										name: '狗蛋',
										age: 0,
										IQ: 10,
										luck: 40,
										// money: 0,
										energyMax: 60,
										energyNow: 60,
										parentMoney: 500,
										health: 60,
										hunger: 50,
										clean: 50,
										happy: 50,
										days: 1,
										healthLogs: [],
										bitCoinCount: 0,
										bitCoinTradeLog: [],
										bitCoinBuyAvg: 0,
										bitCoinProfit: 0,
										changeArr: [213.06, 1824.48, 1913.19, 1000.02, 1500.85, 562.54, 1401.34,
											1847.38,
											986.07, 29.67, 1899.80, 845.65, 301.77, 940.28, 63.72, 1877.40,
											1115.50, 657.85, 1279.25, 80.96, 1381.79, 907.53, 1459.61, 1200.13
										],
										todayWorkCount: 0,
										appearance: 0,
										clothingList: [],
										houseList: [],
										reputation: 0,
										baomuCareDay: 0
									}
									break;
								default:
									break;
							}
						} else {
							// debugger
							this.userInfo = JSON.parse(Database.getData('userInfo'))
							// this.userInfo.parentMoney = this.userInfo.parentMoney
						}


						// this.bitCoinTips = this.userInfo.changeArr[]
						Database.saveData('userInfo', JSON.stringify(this.userInfo))

					},
					nextDay() {



						if (this.userInfo.clean >= 100 && this.userInfo.happy >= 100 && this.userInfo.hunger <= 30) {
							this.userInfo.health += 10
						}

						if (this.userInfo.hunger >= 100) {
							this.userInfo.health -= 13
						} else {
							this.userInfo.health -= Math.floor((this.userInfo.hunger) / 15)
						}
						if(this.userInfo.baomuCareDay == 0){
							this.userInfo.hunger += this.userInfo.hunger < 10 ? 90 : (100 - this.userInfo.hunger)
						}
						
						this.userInfo.health -= Math.floor((100 - this.userInfo.clean) / 15)

						let happyHealthFactor = 1
						if (this.userInfo.happy < 50 && this.userInfo.baomuCareDay == 0) {
							this.userInfo.happy = this.userInfo.happy < 0 ? -this.userInfo.happy : this.userInfo.happy
							happyHealthFactor += Math.floor(this.userInfo.happy / 10)
						}

						this.userInfo.health -= Math.floor((100 - this.userInfo.happy) / 15) * happyHealthFactor



						this.userInfo.luck += Math.random() * 101 > this.userInfo.luck ? 1 : -1

						this.userInfo.health -= Math.floor((80 - this.userInfo.luck) / 15)

						if (this.userInfo.clean >= 70 && this.userInfo.baomuCareDay == 0) {
							this.userInfo.clean -= 70
						} else {
							if(this.userInfo.baomuCareDay == 0){
								this.userInfo.clean = 0
							}
							
						}

						this.userInfo.happy = 70

						this.userInfo.energyNow = this.userInfo.energyMax



						this.userInfo.days += 1
						//特殊节日处理 孩子开心增加
						let date = convertDaysToYearsMonthsDays(this.userInfo.days)
						if (date.years == 0 && date.months == 1 && date.days == 0) {
							this.userInfo.parentMoney += ((4 - this.userInfo.niumaLevel) * 5000)
							mui.alert('孩子满月 收到' + (4 - this.userInfo.niumaLevel) * 5000 + '分子钱', '生日快乐')
						}
						//幼儿园学费  不上幼儿园 每年智力减少 
						if (date.years >= 3 && date.years <= 5 && date.months == 0 && date.days == 0) {
							this.userInfo.parentMoney -= 5000
							mui.alert('交幼儿园学费 花费' + 5000 + '元', '新学期开始咯')
						}

						if (this.userInfo.days % 365 == 0) {
							this.userInfo.IQ += parseInt((7 * calIntAvgByArr(this.userInfo.healthLogs) / 100))
						}

						this.userInfo.health = this.userInfo.health > 100 ? 100 : this.userInfo.health

						this.userInfo.healthLogs.push(parseInt(this.userInfo.health))

						for (var i = 0; i < this.userInfo.clothingList.length; i++) {
							if (this.userInfo.clothingList[i].expire > 0) {
								this.userInfo.clothingList[i].expire -= 1
							}
						}


						if(this.userInfo.baomuCareDay > 0){
							this.userInfo.baomuCareDay -= 1
						}
						
						Database.saveData('userInfo', JSON.stringify(this.userInfo))
						this.randomCoinEvent()
						this.calProfit()

						this.userInfo.todayWorkCount = 0

						

						mui.toast('又过了一天')
						if (this.userInfo.health <= 0) {
							Database.deleteData('userInfo')
							mui.alert('你娃挂了', function() {
								document.location.href = 'birth.html'
							})

							return
						}
					},
					weinai() {

						if (this.userInfo.energyNow < 10) {
							mui.toast('大人没体力了  累了 不能喂奶了')
							return
						}

						if (this.userInfo.hunger <= 0) {
							mui.toast('宝宝不饿了')
						} else if (this.userInfo.parentMoney <= 0) {
							mui.toast('没钱买奶粉了')
						} else {
							this.userInfo.parentMoney -= 10
							this.userInfo.hunger -= 20
							this.userInfo.clean -= 5
							this.userInfo.happy += 10
							this.userInfo.energyNow -= 10

							mui.toast('饥饿感 -10 ！！！')
						}

						Database.saveData('userInfo', JSON.stringify(this.userInfo))
					},
					douhaizi() {
						if (this.userInfo.energyNow < 5) {
							mui.toast('大人没体力了  累了 不能逗孩子')
							return
						}
						if (this.userInfo.happy <= 100) {
							this.userInfo.happy += 10
							this.userInfo.energyNow -= 5
							mui.toast('心情 +10 ！！！')
						} else {
							mui.toast('百分之百开心 抵抗力会变好！！')
						}
						Database.saveData('userInfo', JSON.stringify(this.userInfo))
					},
					kanbing() {
						if (this.userInfo.energyNow < 10) {
							mui.toast('大人没体力了  累了 不能带孩子去看病')
							return
						}
						if (this.userInfo.health >= 80) {
							this.userInfo.energyNow -= 10
							this.userInfo.clean -= 5
							this.userInfo.happy -= 10
							this.userInfo.hunger += 10
							mui.toast('孩子很健康 挂号费 -50 ！')
						} else {
							let num = 100
							if (this.userInfo.health >= 60 && this.userInfo.health < 80) {
								num = 200
							} else if (this.userInfo.health >= 55 && this.userInfo.health < 60) {
								num = 400
							} else if (this.userInfo.health >= 50 && this.userInfo.health < 55) {
								num = 800
							} else if (this.userInfo.health >= 40 && this.userInfo.health < 50) {
								num = 1600
							} else if (this.userInfo.health >= 20 && this.userInfo.health < 40) {
								num = 16000
							} else if (this.userInfo.health >= 1 && this.userInfo.health < 20) {
								num = 160000
							}
							let money = Math.floor(Math.random() * 100) + (80 - this.userInfo.health) * 10 + num
							this.userInfo.health = 80
							this.userInfo.parentMoney -= money
							mui.toast('本次治疗花费' + money + '元！')
						}
						Database.saveData('userInfo', JSON.stringify(this.userInfo))
					},
					xizao() {
						if (this.userInfo.energyNow < 5) {
							mui.toast('大人没体力了  累了 不能带孩子洗澡了')
							return
						}
						if (this.userInfo.clean <= 100) {
							this.userInfo.clean += 40
							this.userInfo.energyNow -= 5
							this.userInfo.happy -= 5
							this.userInfo.parentMoney -= 5
							mui.toast('干净度 +10 !!')
						} else {
							mui.toast('孩子很干净了')
						}
						Database.saveData('userInfo', JSON.stringify(this.userInfo))
					},
					makeMoney() {
						if (this.userInfo.energyNow <= 0) {
							mui.toast('体力不足 无法打工')
							return
						}

						if (this.userInfo.todayWorkCount < 3) {
							document.location.href = 'makeMoney.html'
						} else {
							mui.toast('今日打工次数已达上限')
						}

					},
					chaoBitCoin() {
						if (this.userInfo.energyNow > 0) {
							Database.saveData('userInfo', JSON.stringify(this.userInfo))
							document.location.href = 'bitCoin.html'
						} else {
							mui.toast('体力不足 该休息了')
						}

					},
					coinPriceChange() {
						// this.randomCoinEvent()
						// console.log(this.changeArr)
						this.userInfo.changeArr.splice(0, 1)
						// function getRandomNumber(min, max) {
						//   return Math.floor(Math.random() * (max - min + 1)) + min;
						// }
						let change = ((Math.random() * (100 - (-100)) + 1) - 100).toFixed(2)
						this.bitCoinTips = change > 0 ? '涨' : '跌'
						let newPrice = this.userInfo.changeArr[this.userInfo.changeArr.length - 1] + parseFloat(change)
						console.log(change)
						if (newPrice >= 1) {
							for (var i = 0; i < 1; i++) {
								this.userInfo.changeArr.push(newPrice)
							}
							// console.log(this.changeArr[this.changeArr.length - 1])
						} else {
							this.userInfo.changeArr.push(1)
						}
						// this.bitCoinTips = newPrice
						// this.userInfo.changeArr = this.changeArr
						Database.saveData('userInfo', JSON.stringify(this.userInfo))
						// console.log(this.changeArr[this.changeArr.length - 1])
						// this.initChart()
					},
					randomCoinEvent() {
						if (Math.random() > 0.9) {

							this.userInfo.changeArr.splice(0, 1)
							if (this.userInfo.changeArr[this.userInfo.changeArr.length - 1] < 10) {
								let change = ((Math.random() * (2500 - (1000)) + 1) + 1000).toFixed(2)
								let newPrice = this.userInfo.changeArr[this.userInfo.changeArr.length - 1] + parseFloat(
									change)
								this.userInfo.changeArr.push(parseFloat(newPrice))
								// mui.alert('行情大涨!')
								this.bitCoinTips = '大涨'
							} else {


								let change = ((Math.random() * (2000 - (-2000)) + 1) - 2000).toFixed(2)

								if (((change > 0 ? change : -change) / this.userInfo.changeArr[this.userInfo.changeArr
										.length - 1]) >
									0.5 && change < 0) {
									// mui.alert('行情暴跌!')
									this.bitCoinTips = '大跌'
								}

								if (((change > 0 ? change : -change) / this.userInfo.changeArr[this.userInfo.changeArr
										.length - 1]) >
									0.5 && change > 0) {
									// mui.alert('小涨一波!')
									this.bitCoinTips = '大涨'
								}

								let newPrice = this.userInfo.changeArr[this.userInfo.changeArr.length - 1] + parseFloat(
									change)
								if (newPrice >= 1) {
									this.userInfo.changeArr.push(parseFloat(newPrice))
								} else {
									this.userInfo.changeArr.push(1)
								}
							}
							// this.initChart()

						} else {
							this.coinPriceChange()
						}


					},
					calProfit() {
						this.calBuyAvg()
						let now = parseFloat((this.userInfo.changeArr[this.userInfo.changeArr.length - 1]).toFixed(2))
						this.userInfo.bitCoinProfit = this.userInfo.bitCoinCount * (now - this.calBuyAvg())
						Database.saveData('userInfo', JSON.stringify(this.userInfo))
					},
					calBuyAvg() {
						let sum = 0
						let count = 0
						for (var i = 0; i < this.userInfo.bitCoinTradeLog.length; i++) {
							if (this.userInfo.bitCoinTradeLog[i].type == 'buy') {
								sum += (this.userInfo.bitCoinTradeLog[i].price * this.userInfo.bitCoinTradeLog[i].num)
								count += this.userInfo.bitCoinTradeLog[i].num
							}
						}
						return parseInt(this.userInfo.bitCoinCount) == 0 ? 0 : parseFloat((sum / count).toFixed(2))
					},
					toClothingStore() {
						document.location.href = 'clothingStore.html'
					},
					toHouse() {
						
						if(this.userInfo.appearance >=200){
							document.location.href = 'house.html'
						}else{
							mui.toast('衣冠不整 恕不招待(形象分<200)')
						}
						
					},
					moreMoney() {
						// let that = this
						// mui.prompt('', ' ', 'moreMoney', ['yes', 'cancel', '???'], function(e) {
						// 	if (e.index == 0) {
						// 		mui.toast('1')
						// 		that.userInfo.parentMoney = parseInt(e.value)
						// 		Database.saveData('userInfo', JSON.stringify(that.userInfo))
						// 	} else {}

						// }, 'div')
					},
					rentBaomu(){
						let that = this
						let buyMax = Math.floor(this.userInfo.parentMoney / 200)
						mui.prompt('当前价格:' + '每天200 可负责孩子喂奶和洗澡', '最大可雇佣天数:' + buyMax, '雇佣信息', ['确认雇佣', '取消雇佣'], function(e) {
							let buyNum = parseInt(e.value)
							if (e.index == 0) {
								// console.log(typeof(e.value)=='number')
								if (buyNum <= buyMax && buyNum >= 1) {
									that.userInfo.parentMoney -= (buyNum * 200)
									that.userInfo.baomuCareDay += buyNum
									// if(that.userInfo.bitCoinTradeLog.length==10){
									// 	that.userInfo.bitCoinTradeLog.splice(0,1)
									// }
									// that.userInfo.bitCoinTradeLog.push({
									// 	type: 'buy',
									// 	price: now,
									// 	num: buyNum
									// })
									// that.userInfo.bitCoinBuyAvg = that.calBuyAvg()
									// that.userInfo.bitCoinProfit = parseFloat(that.calProfit().toFixed(2))
									// that.userInfo.parentMoney -= parseInt(buyNum * 200 )
						
									Database.saveData('userInfo', JSON.stringify(that.userInfo))
									mui.toast('雇佣成功')
								} else {
									// that.userInfo.name = e.value
									mui.toast('输入有误', '雇佣失败')
								}
							} else {
								mui.toast('输入有误', '雇佣失败')
							}
						
						}, 'div')
					}
				},
				filters: {
					niumaLevelFilter(val) {
						let res = '幸福'
						switch (val) {
							case 1:
								res = '幸福的'
								return res
								break;
							case 2:
								res = '不幸的'
								return res
								break;
							case 3:
								res = '悲惨的'
								return res
								break;
							default:
								break;
						}
					},
					day2DateFilter(val) {
						// val = 30000
						let res = convertDaysToYearsMonthsDays(val)

						let dateStr = (res.years + '年' + res.months + '月' + res.days + '天')

						return dateStr
					},
					moneyFilter(num) {

						if (num > 100000000) {
							// 数字超过1亿，转换为亿并保留两位小数
							return (num / 100000000).toFixed(2) + '亿';
						} else if (num > 10000000) {
							// 数字超过1千万但不足1亿
							let wan = Math.floor(num / 10000); // 先转换为万
							let qian = Math.floor(wan / 1000) % 10; // 计算千位
							let bai = Math.floor(wan / 100) % 10; // 计算百位
							let shi = Math.floor(wan / 10) % 10; // 计算十位
							let ge = wan % 10; // 计算个位
							return `${qian}${bai}${shi}${ge}万`;
						} else {
							// 如果不超过1千万，直接返回原数字
							return num.toFixed(2);
						}



					},
					reputationFilter(val) {
						if (val == null) {
							return 0
						} else {
							return val.toFixed(2)
						}

					}
				},
				mounted() {
					console.log(this.userInfo.houseList.length)
					this.niumaLevel = Database.getData('niumaLevel')



					// let that = this
					this.initUserInfoByNiumaLevel()
					// mui.prompt('', '默认名字：二狗', '给自己取个响亮的名字吧', ['就这个名字吧', '随便来个名字'], function(e) {
					// 	if (e.index == 1) {
					// 		if (e.value.length == 0) {
					// 			that.userInfo.name = '二狗'
					// 		} else {
					// 			that.userInfo.name = e.value
					// 		}
					// 	} else {
					// 		let random = Math.floor(Math.random() * that.nameList.length)
					// 		that.userInfo.name = that.nameList[random]
					// 	}

					// }, 'div')



					var slider = document.getElementById('Gallery');
					var group = slider.querySelector('.mui-slider-group');
					var items = mui('.mui-slider-item', group);
					//克隆第一个节点
					var first = items[0].cloneNode(true);
					first.classList.add('mui-slider-item-duplicate');
					//克隆最后一个节点
					var last = items[items.length - 1].cloneNode(true);
					last.classList.add('mui-slider-item-duplicate');
					//处理是否循环逻辑，若支持循环，需支持两点：
					//1、在.mui-slider-group节点上增加.mui-slider-loop类
					//2、重复增加2个循环节点，图片顺序变为：N、1、2...N、1
					var sliderApi = mui(slider).slider();

				}
			})
		</script>
	</body>

</html>